import request from '@/utils/request'

/** *
 * 通过用户id获取用户的所有用户权限
 * @param roleId
 */
function findByUserId(userId) {
  return request({
    url: `/sapi/sys/user-permission/search/user-id/${userId}`,
    method: 'post'
  })
}

/** *
 * 保存
 * @param data
 */
function save(userId, userPermissionList) {
  const postData = {}
  postData.userId = userId
  postData.userPermissionListJson = JSON.stringify(userPermissionList)
  return request({
    url: '/sapi/sys/user-permission/save',
    method: 'post',
    data: postData
  })
}

export default {
  findByUserId,
  save
}
